package org.ex;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;


public class Demo {
    public static void main(String[] args) throws ParseException {
        String str = "hello world 中文效果";
        System.out.println(str);

        println(str);

        //时间(日期时间 字符串 Date Calendar LocatDateTime) 转换 时间戳(long数字)
        //String time = "2022-09-12 18:20:30";
        //Calendar calendar = Calendar.getInstance();
        //SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        var time = "2022-09-12 18:20:30";
        var calendar = Calendar.getInstance();
        var simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //Date dd = simple.parse(time); //返回的是java.util.Date
        calendar.setTime(simple.parse(time));

        //Date d2 = new Date("2022/09/12 18:20:30");
        //System.out.printf("%tF %<tT%n",d2);

        //println(simple.parse(time).getTime()); //时间戳 long 毫秒
        println(simple.parse(time).getTime() / 1000);//long 秒
        println(calendar.get(Calendar.HOUR_OF_DAY));
        println(calendar.get(11));

        //System.out.printf("%tF %<tT%n",1662978030000L);
        //System.out.printf("%tF %<tT%n",0L);

    }

    /**
     * Description: 输出对象并换行
     *
     * @date: 2023/6/9 16:04
     * @params: [java.lang.Object]
     * @return: void
     */
    public static void println(Object obj) {
        System.out.println(obj);
    }

}
